home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PASWIZ20 / MOUSE.PAS < prev    next >
Pascal/Delphi Source File  |  1994-11-04  |  4KB  |  145 lines

  1. {   +----------------------------------------------------------------------+
  2.     |                                                                      |
  3.     |        PasWiz  Copyright (c) 1990-1994  Thomas G. Hanlin III         |
  4.     |                                                                      |
  5.     +----------------------------------------------------------------------+
  6.  
  7.  
  8.  
  9. Mouse:
  10.  
  11.    This unit provides mouse support by direct access to the Microsoft mouse
  12.    driver.  It will also work with compatible drivers, such as those produced
  13.    by Logitech and many other companies.  Trackballs and other devices that
  14.    use compatible drivers are likewise fine.
  15.  
  16.    Note that PS/2 computers have rather unusual mouse support, due to an
  17.    incomprehensible decision by IBM.  To the best of my knowledge, these
  18.    routines will not work at all with PS/2 rodents.
  19.  
  20. }
  21.  
  22.  
  23.  
  24. UNIT Mouse;
  25.  
  26.  
  27.  
  28. INTERFACE
  29.  
  30.  
  31.  
  32. FUNCTION Init: Integer;
  33. FUNCTION LeftButton: Boolean;
  34. FUNCTION MidButton: Boolean;
  35. FUNCTION RightButton: Boolean;
  36. FUNCTION WhereX: Integer;
  37. FUNCTION WhereY: Integer;
  38.  
  39. PROCEDURE GotoXY (X, Y: Integer);
  40. PROCEDURE HideCursor;
  41. PROCEDURE Info (VAR Version: Real; VAR Connector, IRQ: Byte);
  42. PROCEDURE LeftClick (VAR Count, X, Y: Integer);
  43. PROCEDURE LeftRelease (VAR Count, X, Y: Integer);
  44. PROCEDURE MidClick (VAR Count, X, Y: Integer);
  45. PROCEDURE MidRelease (VAR Count, X, Y: Integer);
  46. PROCEDURE RightClick (VAR Count, X, Y: Integer);
  47. PROCEDURE RightRelease (VAR Count, X, Y: Integer);
  48. PROCEDURE ShowCursor;
  49. PROCEDURE Window (X1, Y1, X2, Y2: Integer);
  50.  
  51.  
  52.  
  53. { --------------------------------------------------------------------------- }
  54.  
  55.  
  56.  
  57. IMPLEMENTATION
  58.  
  59.  
  60.  
  61. USES
  62.    Dos;
  63.  
  64.  
  65.  
  66. VAR
  67.    Reg: Registers;
  68.  
  69.  
  70.  
  71. { ---- procs to access the mouse driver ----------------------------------- }
  72.  
  73.  
  74.  
  75.  
  76. { range to which to restrict the mouse cursor }
  77. PROCEDURE Window (X1, Y1, X2, Y2: Integer);
  78. BEGIN
  79.    Reg.AX := 7;
  80.    Reg.CX := Y1;
  81.    Reg.DX := Y2;
  82.    Intr($33, Reg);
  83.    Reg.AX := 8;
  84.    Reg.CX := X1;
  85.    Reg.DX := X2;
  86.    Intr($33, Reg);
  87. END;
  88.  
  89.  
  90.  
  91. { basic mouse hardware/software info }
  92. PROCEDURE Info (VAR Version: Real; VAR Connector, IRQ: Byte);
  93. BEGIN
  94.    Reg.AX := 36;
  95.    Intr($33, Reg);
  96.    Version := (Hi(Reg.BX) DIV 16) * 10 + (Hi(Reg.BX) MOD 16)
  97.            + ((Lo(Reg.BX) DIV 16) * 10 + (Lo(Reg.BX) MOD 16)) / 100;
  98.    Connector :=  Hi(Reg.CX);
  99.    IRQ := Lo(Reg.CX);
  100.    { attempt to safeguard against incompatible or outdated drivers }
  101.    IF (Connector < 1) OR (Connector > 20) OR (IRQ = 1) OR (IRQ > 15) THEN BEGIN
  102.       Version := 0.0;
  103.       Connector := 0;
  104.       IRQ := 0;
  105.    END;
  106. END;
  107.  
  108.  
  109.  
  110. {$F+}
  111.  
  112. { the below routines are in assembly language }
  113.  
  114.  
  115.  
  116. FUNCTION Init; external;               { init mouse driver, return buttons }
  117. PROCEDURE HideCursor; external;        { hide mouse cursor }
  118. FUNCTION LeftButton; external;         { return left button status }
  119. FUNCTION MidButton; external;          { return middle button status }
  120. FUNCTION RightButton; external;        { return right button status }
  121. PROCEDURE ShowCursor; external;        { show mouse cursor }
  122. FUNCTION WhereX; external;             { return X coordinate of mouse }
  123. FUNCTION WhereY; external;             { return Y coordinate of mouse }
  124.  
  125. PROCEDURE GotoXY (X, Y: Integer); external;      { set mouse cursor position }
  126.  
  127. { get # of presses of a button & cursor location at last press }
  128. PROCEDURE LeftClick (VAR Count, X, Y: Integer); external;
  129. PROCEDURE MidClick (VAR Count, X, Y: Integer); external;
  130. PROCEDURE RightClick (VAR Count, X, Y: Integer); external;
  131.  
  132. { get # of releases of a button & cursor location at last release }
  133. PROCEDURE LeftRelease (VAR Count, X, Y: Integer); external;
  134. PROCEDURE MidRelease (VAR Count, X, Y: Integer); external;
  135. PROCEDURE RightRelease (VAR Count, X, Y: Integer); external;
  136.  
  137.  
  138. {$L MOUSES}
  139.  
  140.  
  141.  
  142. { ----------------------- initialization code --------------------------- }
  143. BEGIN
  144. END.
  145.